package com.ruoyi.web.controller.bookingMiniProgramSettings;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MiniProgramDisplayConfig;
import com.ruoyi.system.service.IMiniProgramDisplayConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小程序显示设置 Controller
 *
 * @author ruoyi
 * @date 2025-05-16
 */
@Api(tags="小程序显示设置")
@RestController
@RequestMapping("/system/miniProgramDisplayConfig")
public class MiniProgramDisplayConfigController extends BaseController
{
    @Autowired
    private IMiniProgramDisplayConfigService miniProgramDisplayConfigService;

    /**
     * 查询小程序显示设置列表
     */
    @ApiOperation("查询小程序显示设置列表")
    @PreAuthorize("@ss.hasPermi('system:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiniProgramDisplayConfig miniProgramDisplayConfig)
    {
        startPage();
        List<MiniProgramDisplayConfig> list = miniProgramDisplayConfigService.selectMiniProgramDisplayConfigList(miniProgramDisplayConfig);
        return getDataTable(list);
    }

    /**
     * 导出小程序显示设置列表
     */
    @ApiOperation("导出小程序显示设置列表")
    @PreAuthorize("@ss.hasPermi('system:config:export')")
    @Log(title = "小程序显示设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiniProgramDisplayConfig miniProgramDisplayConfig)
    {
        List<MiniProgramDisplayConfig> list = miniProgramDisplayConfigService.selectMiniProgramDisplayConfigList(miniProgramDisplayConfig);
        ExcelUtil<MiniProgramDisplayConfig> util = new ExcelUtil<MiniProgramDisplayConfig>(MiniProgramDisplayConfig.class);
        util.exportExcel(response, list, "小程序显示设置数据");
    }

    /**
     * 通过id获取小程序显示设置详细信息
     */
    @ApiOperation("通过id获取小程序显示设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(miniProgramDisplayConfigService.selectMiniProgramDisplayConfigById(id));
    }

    /**
     * 新增小程序显示设置
     */
    @ApiOperation("新增小程序显示设置")
    @PreAuthorize("@ss.hasPermi('system:config:add')")
    @Log(title = "小程序显示设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiniProgramDisplayConfig miniProgramDisplayConfig)
    {
        return toAjax(miniProgramDisplayConfigService.insertMiniProgramDisplayConfig(miniProgramDisplayConfig));
    }

    /**
     * 修改小程序显示设置
     */
    @ApiOperation("修改小程序显示设置")
    @PreAuthorize("@ss.hasPermi('system:config:edit')")
    @Log(title = "小程序显示设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiniProgramDisplayConfig miniProgramDisplayConfig)
    {
        return toAjax(miniProgramDisplayConfigService.updateMiniProgramDisplayConfig(miniProgramDisplayConfig));
    }

    /**
     * 通过id批量删除小程序显示设置信息
     */
    @ApiOperation("通过id批量删除小程序显示设置信息")
    @PreAuthorize("@ss.hasPermi('system:config:remove')")
    @Log(title = "小程序显示设置（含联系电话）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(miniProgramDisplayConfigService.deleteMiniProgramDisplayConfigByIds(ids));
    }
}
